package cn.smile.commons.enums.core;

import lombok.Getter;
import org.springframework.util.ObjectUtils;

import java.util.Objects;

@Getter
public enum WishStatusEnum {
    /**
     * 未完成
     */
    UNCOMPLETED(0, "未完成"),
    /**
     * 已完成
     */
    COMPLETED(1, "已完成"),
    /**
     * 已放弃
     */
    GIVEN_UP(2, "已放弃"),
    /**
     * 未知
     */
    NULL(-1, "未知");

    private final Integer sn;
    private final String msg;

    WishStatusEnum(Integer sn, String msg) {
        this.sn = sn;
        this.msg = msg;
    }

    public static WishStatusEnum get(Integer code) {
        if (!ObjectUtils.isEmpty(code)) {
            for (WishStatusEnum status : values()) {
                if (Objects.equals(status.getSn(), code)) {
                    return status;
                }
            }
        }
        return NULL;
    }
}
